<template>
  <div>
    <ul>
      <li v-for="(val,index) in arr" :key="index">{{val}}</li> 
    </ul>
    <button @click="revBtn">数组翻转</button>
    <button @click="sliceBtn">截取数组前3个</button>
    <button @click="updateBtn">更新第一个数的值</button>
  </div>
</template>

<script>
export default {
  data(){
    return {
      arr:[1,2,3,4,5]
    }
  },
  methods:{
    revBtn(){
      this.arr.reverse()
    },
    sliceBtn(){
      // console.log(this.arr.slice(0,3));
      let newArr =this.arr.slice(0,3)
      this.arr=newArr
    },
    updateBtn(){
    //  console.log(this.arr[0]=100)
    this.$set(this.arr,0,1000)
    
    }
  }
}
</script>

<style>

</style>